package com.wyzz.hr.action;

import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.wyzz.hr.base.wf.leaverequest.LrWfApproverAction;
import com.wyzz.hr.bo.ILeaverequestBO;
import com.wyzz.hr.util.Pager;
import com.wyzz.hr.vo.ExaminSearchBean;
import com.wyzz.hr.vo.LeaveFormBean;

public class HRLeaveSearchAction extends LrWfApproverAction {

	public HRLeaveSearchAction() {
	}

	public String execute() throws Exception {
		initLRLists();
		actionSrc = "hrLeaveSearch.action";
		if (page == null) {
			page = new Pager();
			page.setOrder("");
		} else if (page.getOrder().trim().length() == 0)
			page.setOrder("");
		if (es_Bean == null)
			es_Bean = new ExaminSearchBean();
		if (lf_Bean == null)
			lf_Bean = new LeaveFormBean();
		ILeaverequestBO lr_BO = (ILeaverequestBO) getBean("leaverequestBO");
		lr_BO.approverHRSearch(es_Bean, page);
		if (!StringUtils.isEmpty(getInfoMeg()))
			addSuccessInfo(getInfoMeg());
		return "success";
	}

	public String hrLeaveApproveOrReject() throws Exception {
		String Ids[] = ServletActionContext.getRequest().getParameterValues(
				"changIds");
		String operate = "approve".equals(approveOper) ? "hr-approve"
				: "hr-reject";
		return wfObjOpBatch(operate, lf_Bean, Ids);
	}

	public void validate() {
		validateDate(es_Bean);
		validateLRStatus(es_Bean);
	}

	public ExaminSearchBean getEs_Bean() {
		return es_Bean;
	}

	public void setEs_Bean(ExaminSearchBean es_Bean) {
		this.es_Bean = es_Bean;
	}

	public Pager getPage() {
		return page;
	}

	public void setPage(Pager page) {
		this.page = page;
	}

	public String getActionSrc() {
		return actionSrc;
	}

	public void setActionSrc(String actionSrc) {
		this.actionSrc = actionSrc;
	}

	public String getInfoMeg() {
		return infoMeg;
	}

	public void setInfoMeg(String infoMeg) {
		this.infoMeg = infoMeg;
	}

	public String getApproveOper() {
		return approveOper;
	}

	public void setApproveOper(String approveOper) {
		this.approveOper = approveOper;
	}

	public LeaveFormBean getLf_Bean() {
		return lf_Bean;
	}

	public void setLf_Bean(LeaveFormBean lf_Bean) {
		this.lf_Bean = lf_Bean;
	}

	public String getLrUpdateId() {
		return lrUpdateId;
	}

	public void setLrUpdateId(String lrUpdateId) {
		this.lrUpdateId = lrUpdateId;
	}

	public String getSrcAction() {
		return srcAction;
	}

	public void setSrcAction(String srcAction) {
		this.srcAction = srcAction;
	}

	public String getRejectLog() {
		return rejectLog;
	}

	public void setRejectLog(String rejectLog) {
		this.rejectLog = rejectLog;
	}

	private static final long serialVersionUID = 1L;
	private ExaminSearchBean es_Bean;
	private Pager page;
	private String actionSrc;
	private String srcAction;
	private String infoMeg;
	private String approveOper;
	private String rejectLog;
	private LeaveFormBean lf_Bean;
	private String lrUpdateId;
}
